package com.jingxuan.common.constant;

/**
 * Redis Key常量
 */
public class RedisKeyConstants {
    
    /**
     * Token Key前缀
     * 格式：token:userId
     */
    public static final String TOKEN_PREFIX = "token:";
    
    /**
     * 购物车Key前缀
     * 格式：cart:userId
     */
    public static final String CART_PREFIX = "cart:";
    
    /**
     * 商品缓存Key前缀
     * 格式：product:productId
     */
    public static final String PRODUCT_PREFIX = "product:";
    
    /**
     * 用户信息缓存Key前缀
     * 格式：user:userId
     */
    public static final String USER_PREFIX = "user:";

    /**
     * 所有商品类型缓存Key前缀
     * 格式：products_type
     */
    public static final String PRODUCTS_TYPE_PREFIX = "products_type";

    /**
     * 用户行为缓存Key前缀
     * 格式：behavior:user:{userId}
     */
    public static final String USER_BEHAVIOR_PREFIX = "behavior:user:";

    /**
     * 关键词-用户集合Key前缀
     * 格式：behavior:keyword:users:{keyword}
     */
    public static final String KEYWORD_USERS_PREFIX = "behavior:keyword:users:";

    /**
     * 商品浏览-用户集合Key前缀
     * 格式：behavior:product:users:{productId}
     */
    public static final String PRODUCT_USERS_PREFIX = "behavior:product:users:";
    
    /**
     * 获取Token的完整Key
     */
    public static String getTokenKey(Long userId) {
        return TOKEN_PREFIX + userId;
    }
    
    /**
     * 获取购物车的完整Key
     */
    public static String getCartKey(Long userId) {
        return CART_PREFIX + userId;
    }
    
    /**
     * 获取商品缓存的完整Key
     */
    public static String getProductKey(String productId) {
        return PRODUCT_PREFIX + productId;
    }
    
    /**
     * 获取用户信息缓存的完整Key
     */
    public static String getUserKey(Long userId) {
        return USER_PREFIX + userId;
    }
}

